﻿namespace System.ServiceModel.DomainServices.Client
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public sealed class EntityQuery<TEntity> : EntityQuery where TEntity: Entity
    {
        internal EntityQuery(EntityQuery eq, IQueryable<TEntity> query) : base(eq, query)
        {
        }

        internal EntityQuery(DomainClient domainClient, string queryName, IDictionary<string, object> parameters, bool hasSideEffects, bool isComposable) : base(domainClient, queryName, typeof(TEntity), parameters, hasSideEffects, isComposable)
        {
        }

        internal IQueryable<TEntity> Query
        {
            get
            {
                return (IQueryable<TEntity>) base.Query;
            }
            set
            {
                base.Query = value;
            }
        }

        internal IQueryable<TEntity> QueryRoot
        {
            get
            {
                return (this.Query ?? new TEntity[0].AsQueryable<TEntity>());
            }
        }
    }
}

